package com.ruoyi.web.controller.ism;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ism.domain.IsmIntegralRecord;
import com.ruoyi.ism.service.IIsmIntegralRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 积分记录Controller
 * 
 * @author ruoyi
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/ism/integralRecord")
public class IsmIntegralRecordController extends BaseController
{
    @Autowired
    private IIsmIntegralRecordService ismIntegralRecordService;

    /**
     * 查询积分记录列表
     */
    @PreAuthorize("@ss.hasPermi('ism:integralRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(IsmIntegralRecord ismIntegralRecord)
    {
        startPage();
        List<IsmIntegralRecord> list = ismIntegralRecordService.selectIsmIntegralRecordList(ismIntegralRecord);
        return getDataTable(list);
    }

    /**
     * 导出积分记录列表
     */
    @PreAuthorize("@ss.hasPermi('ism:integralRecord:export')")
    @Log(title = "积分记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IsmIntegralRecord ismIntegralRecord)
    {
        List<IsmIntegralRecord> list = ismIntegralRecordService.selectIsmIntegralRecordList(ismIntegralRecord);
        ExcelUtil<IsmIntegralRecord> util = new ExcelUtil<IsmIntegralRecord>(IsmIntegralRecord.class);
        util.exportExcel(response, list, "积分记录数据");
    }

    /**
     * 获取积分记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ism:integralRecord:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(ismIntegralRecordService.selectIsmIntegralRecordByRecordId(recordId));
    }

    /**
     * 新增积分记录
     */
    @PreAuthorize("@ss.hasPermi('ism:integralRecord:add')")
    @Log(title = "积分记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IsmIntegralRecord ismIntegralRecord)
    {
        return toAjax(ismIntegralRecordService.insertIsmIntegralRecord(ismIntegralRecord));
    }

    /**
     * 修改积分记录
     */
    @PreAuthorize("@ss.hasPermi('ism:integralRecord:edit')")
    @Log(title = "积分记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IsmIntegralRecord ismIntegralRecord)
    {
        return toAjax(ismIntegralRecordService.updateIsmIntegralRecord(ismIntegralRecord));
    }

    /**
     * 删除积分记录
     */
    @PreAuthorize("@ss.hasPermi('ism:integralRecord:remove')")
    @Log(title = "积分记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(ismIntegralRecordService.deleteIsmIntegralRecordByRecordIds(recordIds));
    }
}
